package cn.yx.framework.exception;

import java.util.HashMap;

/**
 * Created by Administrator on 2017-02-10.
 */
public class DataNotFoundException extends BasicException {
    private static final int CODE_DATA_NOT_FOUND_EXCEPTION = 5201;
    private String primaryId;
    private Object entity;

    public DataNotFoundException(String primaryId) {
        this(primaryId, (Object)null);
    }

    public DataNotFoundException(String primaryId, Object entity) {
        this(5201, "记录不存在", primaryId, entity);
    }

    public DataNotFoundException(int code, String message, String primaryId, Object entity) {
        super(code, message);
        this.primaryId = primaryId;
        this.entity = entity;
    }

    protected Object getData() {
        return new HashMap() {
            {
                this.put("id", DataNotFoundException.this.primaryId);
                this.put("entity", DataNotFoundException.this.entity);
            }
        };
    }
}
